package main

import (
	"fmt"
	"log"
	"os"

	"navigation-service/internal/database"
	"navigation-service/internal/handlers"
	"navigation-service/internal/routes"

	"github.com/gin-gonic/gin"
)

func main() {
	// 初始化数据库
	database.InitDB()
	defer database.CloseDB()

	// 加载导航数据
	handlers.LoadNavigationData()

	// 创建Gin路由
	r := gin.Default()

	// 设置路由
	routes.SetupRoutes(r)

	// 启动服务器
	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"
	}

	fmt.Printf("导航服务启动在端口 %s\n", port)
	fmt.Printf("访问地址: http://localhost:%s\n", port)
	log.Fatal(r.Run(":" + port))
}
